package com.tinxing.bp.modules.login.controller;

import com.tinxing.bp.base.controller.BaseController;
import com.tinxing.bp.commons.utils.tips.ResponseTip;
import com.tinxing.bp.modules.login.entity.vo.LoginBean;
import com.tinxing.bp.modules.user.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @description: 登录控制器
 * @author: znegyu
 * @create: 2021-01-09 15:25
 **/
@Api(value = "登录相关接口", tags = "登录相关接口")
@RestController
@RequestMapping("/admin/user")
public class LoginController extends BaseController {
    @Resource
    private IUserInfoService userInfoService;

    /**
     * 通过账号密码登录
     * 账号:用户手机号码(唯一标识符)
     * 密码:默认是(tul3933)
     *
     * @param loginBean 登录所需数据
     * @return 包含token的json
     */
    @ApiOperation("用户登录")
    @PostMapping("/login")
    public ResponseTip<Map<String, String>> login(@RequestBody LoginBean loginBean) {
        return successTip(userInfoService.authentication(loginBean));
    }
}
